from django import template
register = template.Library()

@register.inclusion_tag('menu.html')
def menu_tag(request):
    current_path = request.path
    menu_data = request.session.get('menu_data')
    # menu_data = [{'title': '查看信息', 'url': '/manage/'}, {'title': '角色管理', 'url': '/role_manage/', 'class': 'menu_color'},
    #  {'title': '用户管理', 'url': '/user_manage/'}]
    print(menu_data)
    for i in menu_data:
        if current_path == i['url']:
            i['class'] = 'menu_color'
    return {'menu_dict':menu_data}